﻿using B.S.BasicData.ErrorCode;
using B.S.BasicData.Read.Apilication.Common.Delparment;
using B.S.BasicData.Read.DTOS;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class DelparmentController : ControllerBase
    {
        private readonly IMediator mediator;

        public DelparmentController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 角色信息分配
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<SetuserDTO>>> GetDelparmentNameHandle([FromQuery]GetDelparmentNameCommon request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 根据角色信息反填用户
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<SetuserDTO>>> UpdateRole([FromQuery] GetoneRoleCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 部门下拉
        /// </summary>
        /// <param name="common"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<DelparmentDTO>>> DelparmentShow([FromQuery] GetDelparmentCommon common)
        {
            return mediator.Send(common);
        }
    }
}
